<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:replace="fragments/common :: head" />
<body>
	<div th:replace="fragments/common :: bootstrap" />
	<div th:include="fragments/common :: admin (${isAdmin})" />
	
	<div th:if="${isAdmin}">
		<div class="portletBody">
			<div id="menu" th:include="fragments/menus :: main (credentials)" />
			<div class="page-header">
				<h1 th:text="#{credentials_title}"></h1>
			</div>
			
			<div th:include="fragments/common :: error" />
			<div class="sak-banner-success" th:if="${test_message != null}" th:text="${test_message}"></div>
			
			<form class="form-horizontal" th:action="@{/save-credentials}" method="post">
				<div class="form-group">
					<label class="col-md-2" th:text="#{credentials.authority}"></label>
					<div class="col-md-4">
						<input class="form-control" name="authority" th:value="${credentials.authority}" placeholder="https://login.microsoftonline.com/..." />
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-md-2" th:text="#{credentials.clientId}"></label>
					<div class="col-md-4">
						<input class="form-control" name="clientId" th:value="${credentials.clientId}" th:placeholder="#{credentials.clientId}" />
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-md-2" th:text="#{credentials.secret}"></label>
					<div class="col-md-4">
						<input class="form-control" type="password" name="secret" th:value="${credentials.secret}" th:placeholder="#{credentials.secret}" />
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-md-2" th:text="#{credentials.scope}"></label>
					<div class="col-md-4">
						<input class="form-control" name="scope" th:value="${credentials.scope}" th:placeholder="#{credentials.scope_alt(${T(org.sakaiproject.microsoft.api.MicrosoftAuthorizationService).SCOPE_DEFAULT})}"/>
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-md-2" th:text="#{credentials.delegated_scope}"></label>
					<div class="col-md-4">
						<input class="form-control" name="delegatedScope" th:value="${credentials.delegatedScope}" th:placeholder="#{credentials.scope_alt(${T(org.sakaiproject.microsoft.api.MicrosoftAuthorizationService).DELEGATED_SCOPE_DEFAULT})}"/>
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-md-2" th:text="|#{credentials.email}*|"></label>
					<div class="col-md-4">
						<input class="form-control" name="email" th:value="${credentials.email}" th:placeholder="#{credentials.email}"/>
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2"></label>
					<div class="act col-md-4">
						<input class="active"  type='submit' th:value="#{save}" />
						<input type='button' th:value="#{cancel}" th:onclick="'window.location.href = \'' +@{/index}+ '\''" />
						<input type='button' th:value="#{credentials.test}" onclick="submitTest()"/>
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2"></label>
					<div class="col-md-4">
						<div class="instruction" th:text="|* #{credentials.email_info}|"></div>
					</div>
				</div>
			</form>
			
			<form id="test-credentials-form" class="form-horizontal" th:action="@{/test-credentials}">
			</form>
		</div>

		<script th:inline="javascript">
			function submitTest(){
				document.getElementById('test-credentials-form').submit();
			}
		</script>
	</div>
</body>
</html>
